package com.medreams.dao;

import com.medreams.domain.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface UserDao {
    @Select("select * from test")
    //查询一对多 id 主键 column 是对应的使用的键 property 获取到的结果放到这个值上 many 一对多 引入对应的查询的列表 延迟加载
    @Results(@Result(id = true,column = "id",property = "orderList",many = @Many(select="com.medreams.dao.OrderDao.getOrderList",fetchType = FetchType.LAZY)))
    List<User> finAll();

    @Insert("insert into test(user_name,create_time) values(#{user_name},#{create_time})")
    void insertTest(User user);

    @Update("update test set user_name=#{user_name} where id = #{id}")
    void updateTest(User user);

    @Delete("delete from test where id = #{id}")
    void deleteTest(Integer userId);

    @Select("select * from test where id = #{id}")//提供一对一的数据
    User getTestInfo(Integer id);
}
